package com.permission.model;

import com.fasterxml.jackson.annotation.*;
import com.solution.framework.model.BaseBean;
import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import javax.persistence.*;

/**
* Created with generator tools.
* User: sunguangzhu
* DateTime:2014-04-28 09:39:13
*/
@Entity
@Table(name = "t_p_resource")
public class PResource extends BaseBean implements java.io.Serializable {

/**
* 名称
*/
private java.lang.String name;

/**
* 菜单文本
*/
private java.lang.String menuText;

/**
* 菜单类型
*/
private java.lang.Boolean type;

/**
* 地址
*/
private java.lang.String url;

/**
* 上级资源
*/
private  com.permission.model.PResource parent;

/**
* 角色资源集合
*/
private java.util.Set<com.permission.model.PRoleResource> pRoleResources;

/** default constructor */
public PResource() {
}

/**
* full constructor
* @param name
* @param menuText
* @param type
* @param url
* @param parent
* @param pRoleResources
*/
public PResource(java.lang.String name,java.lang.String menuText,java.lang.Boolean type,java.lang.String url, com.permission.model.PResource parent,java.util.Set<com.permission.model.PRoleResource> pRoleResources) {
this.name=name;
this.menuText=menuText;
this.type=type;
this.url=url;
this.parent=parent;
this.pRoleResources=pRoleResources;
}

/**
*  getter
*/
    @Column
public java.lang.String getName() {
return this.name;
}

/**
* setter
* @param name
*/
public void setName(java.lang.String name) {
this.name = name;
}

/**
*  getter
*/
    @Column
public java.lang.String getMenuText() {
return this.menuText;
}

/**
* setter
* @param menuText
*/
public void setMenuText(java.lang.String menuText) {
this.menuText = menuText;
}

/**
*  getter
*/
    @Column
public java.lang.Boolean getType() {
return this.type;
}

/**
* setter
* @param type
*/
public void setType(java.lang.Boolean type) {
this.type = type;
}

/**
*  getter
*/
    @Column
public java.lang.String getUrl() {
return this.url;
}

/**
* setter
* @param url
*/
public void setUrl(java.lang.String url) {
this.url = url;
}

/**
*  getter
*/
    @JsonManagedReference
    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "parent_id")
    @NotFound(action = NotFoundAction.IGNORE)
    @ForeignKey(name = "fk_presource_parent")
public  com.permission.model.PResource getParent() {
return this.parent;
}

/**
* setter
* @param parent
*/
public void setParent( com.permission.model.PResource parent) {
this.parent = parent;
}

/**
*  getter
*/
    @JsonBackReference
    @OneToMany(fetch = FetchType.LAZY, mappedBy = "PResource")
public java.util.Set<com.permission.model.PRoleResource> getPRoleResources() {
return this.pRoleResources;
}

/**
* setter
* @param pRoleResources
*/
public void setPRoleResources(java.util.Set<com.permission.model.PRoleResource> pRoleResources) {
this.pRoleResources = pRoleResources;
}

}
